CXX = g++
CXXFLAGS = -Wall -ansi -pedantic -g

LIBS = -lpthread -lrt

ifeq ($(shell uname),SunOS)
  LIBS += -lsocket -lnsl
endif

all: kdc client server fileclient fileserver

server: Server.h kdcServer.cpp utilities.h randNum.h randNum.cpp Blowfish.h Blowfish.cpp PracticalSocket.h PracticalSocket.cpp Packet.h Packet.cpp crc.cpp crc.h
	$(CXX) $(CXXFLAGS) -o server kdcServer.cpp randNum.cpp Blowfish.cpp PracticalSocket.cpp Packet.cpp crc.cpp $(LIBS)

client: Client.h Client.cpp Blowfish.h Blowfish.cpp PracticalSocket.h PracticalSocket.cpp randNum.h randNum.cpp Packet.h Packet.cpp crc.cpp crc.h
	$(CXX) $(CXXFLAGS) -o client Client.cpp Blowfish.cpp PracticalSocket.cpp randNum.cpp Packet.cpp crc.cpp $(LIBS)

fileserver: Server.cpp utilities.h randNum.h randNum.cpp Blowfish.h Blowfish.cpp PracticalSocket.h PracticalSocket.cpp Packet.h Packet.cpp crc.cpp crc.h
	$(CXX) $(CXXFLAGS) -o server Server.cpp randNum.cpp Blowfish.cpp PracticalSocket.cpp Packet.cpp crc.cpp $(LIBS)

fileclient: fileClient.cpp Blowfish.h Blowfish.cpp PracticalSocket.h PracticalSocket.cpp randNum.h randNum.cpp Packet.h Packet.cpp crc.cpp crc.h
	$(CXX) $(CXXFLAGS) -o client fileClient.cpp Blowfish.cpp PracticalSocket.cpp randNum.cpp Packet.cpp crc.cpp $(LIBS)


kdc: KeyDistributionCenter.h KeyDistributionCenter.cpp Blowfish.h Blowfish.cpp PracticalSocket.h PracticalSocket.cpp
	$(CXX) $(CXXFLAGS) -o kdc KeyDistributionCenter.cpp Blowfish.cpp PracticalSocket.cpp $(LIBS)

clean:
	$(RM) kdc client server fileclient fileserver

